﻿using System;

namespace Sgs.Model
{
    class Hero
    {
        public int HP;
        private int CurrentHP;
        private readonly int Index;
        private readonly string Name;
        private readonly HeroPower Power;
        public readonly int Use杀Times = 1;

        /// <summary>
        /// 为Player提供HP的修改权限
        /// </summary>
        public int PlayerAccessHP
        {
            get
            {
                return CurrentHP;
            }

            set
            {
                if(value > HP)
                {
                    throw new ApplicationException("修改的体力值超过了体力上限");
                } else
                {
                    CurrentHP = value;
                }
            }
        }

        /// <summary>
        /// 武将势力枚举
        /// </summary>
        public enum HeroPower
        {
            魏, 蜀, 吴, 群
        }

        /// <summary>
        /// 定义武将
        /// </summary>
        /// <param name="Name">武将名</param>
        /// <param name="Index">武将唯一编号</param>
        /// <param name="HP">武将体力上限</param>
        /// <param name="Power">武将势力</param>
        /// <param name="Use杀Times">默认出杀次数=1</param>
        public Hero(string Name, int Index, int HP, HeroPower Power, int Use杀Times = 1)
        {
            this.HP = HP;
            CurrentHP = HP;
            this.Index = Index;
            this.Name = Name;
            this.Power = Power;
            this.Use杀Times = Use杀Times;
        }

        public override string ToString()
        {
            return $"武将：{ Name }  势力={  Power } 当前体力值={ CurrentHP } 体力上限={ HP }";
        }

        public void As主公()
        {
            HP = ++CurrentHP;
        }

        public bool IsHealthy()
        {
            return HP == CurrentHP;
        }

        public void Heal(int HealNumber)
        {
            CurrentHP += HealNumber;
            if(CurrentHP > HP)
            {
                CurrentHP = HP;
            }
        }

        public void GetHurt(int HurtNumber)
        {
            CurrentHP -= HurtNumber;
        }

    }
}
